home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 145 / 145.d81 / t.disc b < prev    next >
Text File  |  2022-08-26  |  25KB  |  909 lines

  1.  
  2.     Explorations on IFLI
  3.  
  4.      by Adrian Gonzalez
  5.       and Mike Gordillo
  6.  
  7.  
  8.     Adrian Gonzalez is a true
  9. Commodorian, a rare breed in his
  10. native country of Mexico.  He has
  11. spent the past year or so converting
  12. .gif and .jpeg files into the IFLI
  13. format on the C64.  His endeavours
  14. have allowed many a C64 owner to
  15. enjoy high quality images.
  16.  
  17.  
  18.     [Mike:] Adrian, before we start,
  19. can you give us some background on
  20. what IFLI is and  how it achieves
  21. such stunning images?
  22.  
  23.     [Adrian:] Sure thing.  A little
  24. multicolor bitmap mode and FLI mode
  25. background is in order too.  Images
  26. in the 'regular' multicolor bitmap
  27. mode (MCBM from now on) are divided
  28. in cells or blocks that are 4 pixels
  29. wide and 8 pixels tall.  The screen
  30. is split into 40 columns of these
  31. blocks horizontally and 25
  32. vertically, giving a total of 1000
  33. 4x8 pixel cells or blocks.  A pixel
  34. in one of these blocks can have any
  35. one of 3 colors common to the entire
  36. block, or the background color,
  37. common to the entire screen.  A FLI
  38. picture is similar to a regular MCBM
  39. picture in that it has the same
  40. resolution (160x200), however, it is
  41. more flexible in terms of how many
  42. colors you can use in each 4x8
  43. character block.  This flexibility is
  44. achieved through complex timing
  45. tricks which I'd rather explain in a
  46. future article, but I'll give a very
  47. brief overview of what they make the
  48. VIC-II do.  Basically, the trick is
  49. to fool the VIC chip into fetching
  50. the screen memory data on every
  51. rasterline.  This screen memory data
  52. is responsible for 2 of the 4 colors
  53. available on each 4x8 character block
  54. in MCBM (bit pairs '01' and '10').
  55. So this basically divides each 4x8
  56. cell of MCBM into eight 4x1 cells,
  57. making the VIC chip fetch a different
  58. pair of colors from screen memory for
  59. each rasterline (each 4x1 cell).
  60. This trick gets rid of most of the
  61. restrictions that MCBM imposes, since
  62. now 2 of the 4 pixels in every cell
  63. can have any one of the 16 available
  64. colors.  Chances are the colors
  65. needed for the other two pixels will
  66. be available from either screen
  67. memory, color memory or the
  68. background color.  This flexibility,
  69. of course, does not come without a
  70. price:  storage.  This technique
  71. multiplies the amount of memory
  72. needed for screen data times 8,
  73. adding 7000 bytes when you compare
  74. with a standard koala paint file.
  75. Fortunately, the 8000 bytes needed
  76. for screen memory and the 8000 for
  77. the bitmap fit just right on one 16k
  78. bank (remember the VIC can only 'see'
  79. 16k at a time).
  80.  
  81.     If you are new to these software
  82. screen modes, I recommend you read
  83. the previous part again, especially
  84. because once you get the grasp of FLI
  85. mode, IFLI is a snap.  IFLI mode is
  86. basically two FLI pictures being
  87. rapidly alternated to give the
  88. illusion of more colors.  So where
  89. does the added resolution come in?
  90. Thanks to the VIC-II's hardware, it
  91. is possible to shift the screen up to
  92. 7 hi-res pixels horizontally, even
  93. when in MCBM.  The trick in IFLI is
  94. to display one FLI picture for an
  95. entire screen refresh, then display
  96. the second FLI picture shifted one
  97. hi-res pixel to the right on the next
  98. redraw.  The effects of this are not
  99. so obvious, so I'll illustrate with
  100. an example.  Suppose you have the
  101. first line of FLI picture A and FLI
  102. picture B and it looks like this:
  103.  
  104.  First line of FLI picture A:
  105.   K    G    Y    O   . . .
  106.  
  107.  First line of FLI picture B:
  108.   G    G    Y    O   . . .
  109.  
  110. When you alternate them, shifting
  111. picture B one hi-res pixel to the
  112. right you get:
  113.  
  114.   K    G    Y    O  . . .
  115.      G    G    Y    O  
  116.  ------------------------------
  117.  K KGG G GYY YOO . . .
  118.  
  119.  Where:
  120.  K = Black pixel
  121.  G = Green pixel
  122.  Y = Yellow pixel
  123.  O = Orange pixel
  124.  
  125.     The resulting line has pixels
  126. that are as wide as high resolution
  127. pixels, and that may have colors that
  128. are combinations of the c64's 16
  129. standard colors. It is evident from
  130. this example that IFLI's strengths
  131. lie in reproducing images with smooth
  132. color shades.  The downside of IFLI
  133. is that it flickers, and depending on
  134. the colors that are being alternated,
  135. the flicker can go from barely
  136. noticeable to a stroboscopic light
  137. show.  With this in mind, however,
  138. this display mode can produce some of
  139. the most stunning images that have
  140. ever been displayed on our beloved
  141. C64.  After this brief introduction I
  142. hope the interview will make a little
  143. bit more sense, so let's get on with
  144. it.
  145.  
  146.  
  147.     [Mike:] Adrian, I know you do the
  148. bulk of your conversions on other
  149. platforms for the sake of
  150. expiediency.  However, I'm more
  151. generally interested in how the
  152. pictures get down to the C64 in terms
  153. of the actual display on the C64.
  154.  
  155.     [Adrian:] Well, I start out by
  156. doing careful color analysis on my
  157. Amiga.  This involves pre-processing
  158. the images in programs such as The
  159. Art Department Professional, in order
  160. to adjust the brightness, contrast,
  161. color and size of the source images.
  162. After that, I feed the images to a
  163. conversion utility I wrote that tries
  164. (as best as possible) to map the
  165. colors from the original image to
  166. combinations of the 16 colors of the
  167. c64, taking many factors into
  168. consideration, such as flicker.  The
  169. conversion program has several
  170. settings, which have to do mostly
  171. with dithering and flicker reduction.
  172. It is not always perfect, and the
  173. problem of IFLI flicker is never
  174. truly defeated, but I'm generally
  175. satisfied with the results.
  176.  
  177.  
  178.     [Mike:] Yes, they are beautiful
  179. conversions, but I could never get
  180. them to display with any other IFLI
  181. viewer.
  182.  
  183.     [Adrian:] Since there is no
  184. standard data format for IFLI
  185. pictures I had to come up with my
  186. own.  My ifli's load at $2000, then
  187. the code moves them to the higher
  188. memory and depending on how big they
  189. are, of course, they get depacked
  190. accordingly.
  191.  
  192.  
  193.     [Mike:] Argh, they are packed?
  194.  
  195.     [Adrian:] Of course they are
  196. packed.  When was the last time you
  197. saw two of them having the same size?
  198. :)
  199.  
  200.     [Mike:] What kind of packer did
  201. you use?
  202.  
  203.     [Adrian:] They are packed using a
  204. very simple RLE routine.  If you want
  205. you can use the routines in my viewer
  206. to depack them for you.  They'll set
  207. everything up in the right place.
  208. (e.g. $4000-7fff, $c000-$ffff and
  209. $d800-$dbff).  If anybody is
  210. interested in these routines or the
  211. source code for the viewer, feel free
  212. to mail me and I'll send them your
  213. way.
  214.  
  215.     [Mike:] Why did you split the
  216. data over those addresses?  Is it
  217. safe to assume that IFLI data is
  218. composed of two 16 kbyte blocks for
  219. pic data and then comes the color
  220. info at $d800 on up?
  221.  
  222.     [Adrian:] Yeah, you can look at
  223. it that way.  It's actually two 8k
  224. blocks containing the bitmaps and two
  225. 8k blocks containing the screen
  226. memory.
  227.  
  228.     [Mike:] Ah, I see.  There is one
  229. FLI pic portion in each 8k bitmap and
  230. one 1k block for color memory that is
  231. common to both images.
  232.  
  233.     [Adrian:] Yes, but you know, it
  234. might be interesting if it were
  235. possible to change color memory as
  236. well.  It would give us a slight
  237. boost in the number of apparent
  238. colors.
  239.  
  240.     [Mike:] Could you explain exactly
  241. how, and wouldn't any further memory
  242. tweaking complicate matters more?
  243. Maybe you would need to not use the
  244. entire screen?
  245.  
  246.     [Adrian:] Oh, just mumbling out
  247. loud :).  In practice there is no
  248. time to change color memory on the
  249. fly.  Also, it doesn't matter if you
  250. do IFLI's smaller than the entire
  251. screen (say 1/3 screen IFLI) because
  252. you still have data scattered all
  253. over the same ranges I described
  254. earlier.  The IFLI data must be
  255. placed at certain spots in memory so
  256. that the VIC-II chip can properly
  257. fetch it.
  258.  
  259.     [Mike:] Ok, I understand, but
  260. this 1/3 IFLI screen proposal
  261. intrigues me greatly.  I hear "less
  262. than full-screen" IFLI's may be
  263. doubled-over onto themselves, thereby
  264. giving even more colors or perhaps
  265. leading to run-time IFLI animations.
  266.  
  267.     [Adrian:] This is a possibility,
  268. but you would have even more flicker
  269. than regular IFLI.  I'm not even sure
  270. if the logistics involved will allow
  271. even a 1/3 IFLI to be doubled over.
  272.  
  273.     [Mike:]> Well, if the CPU proves
  274. too slow, what about using the speedy
  275. REU to do the job?
  276.  
  277.     [Adrian:]] Interesting, the
  278. problem is that since I'm not lucky
  279. enough to own one, I do not know how
  280. much overhead it takes to set up the
  281. REU for multiple transfers. For
  282. example, if I wanted to transfer 512
  283. bytes of screen memory, then
  284. reprogram the R